#include <WinTen.h>
#include <Windows.h>
#include <extend.h>

//----------------------------------------------------------------------------//

CLIPPER GETDC() // ( hWnd ) --> hDC
{
   _retnl( ( LONG ) GetDC( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER RELEASEDC() // ( hWnd, hDC ) --> lSuccess
{
   _retl( ReleaseDC( ( HWND ) _parnl( 1 ), ( HDC ) _parnl( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER DELETEDC() // ( hDC ) --> lSuccess
{
   _retl( DeleteDC( ( HDC ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER CREATEDC() // ( cDriver, cDevice, cOutput, cInitData ) --> hDC
{
   _retnl( ( LONG ) CreateDC( _parc( 1 ), _parc( 2 ), _parc( 3 ),
           ( DEVMODE * ) IF( ISCHAR( 4 ), _parc( 4 ), 0 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER SETWINDOWE() //  XT( hDC, nUnitsWidth, nUnitsHeight ) --> aPrevDimensions
{
   SIZE size;

   SetWindowExtEx( ( HDC ) _parnl( 1 ),
                   ( int ) _parni( 2 ),
                   ( int ) _parni( 3 ), &size );
   _reta( 2 );
   _storni( size.cx, -1, 1 );
   _storni( size.cy, -1, 2 );
}

//----------------------------------------------------------------------------//

CLIPPER SETVIEWPOR()  // TEXT( hDC, nWidth, nHeight ) --> aPrevDimensions
{
   SIZE size;

   SetViewportExtEx( ( HDC ) _parnl( 1 ),
                     ( int ) _parni( 2 ),
                     ( int ) _parni( 3 ), &size );
   _reta( 2 );
   _storni( size.cx, -1, 1 );
   _storni( size.cy, -1, 2 );
}

//----------------------------------------------------------------------------//

CLIPPER SETVIEWORG()  // TEXT( hDC, nWidth, nHeight ) --> aPrevDimensions
{
   POINT pt;
   DWORD dwPrev = SetViewportOrgEx( ( HDC ) _parnl( 1 ),
                                    ( int ) _parni( 2 ),
                                    ( int ) _parni( 3 ), &pt );
   _reta( 2 );
   _storni( LOWORD( dwPrev ), -1, 1 );
   _storni( HIWORD( dwPrev ), -1, 2 );
}


//----------------------------------------------------------------------------//

CLIPPER SAVEDC() // ( hDC ) --> nSavedDev
{
  _retni( SaveDC( ( HDC ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER RESTOREDC() // ( hDC ) --> lSuccess
{
  _retl( RestoreDC( ( HDC ) _parnl( 1 ), -1 ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETWINDOWD()// C( hWnd ) --> hEntireDC
{
   _retnl( ( LONG ) GetWindowDC( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//
